//
//  StrokeViewContainer.h
//  StrokeDemo
//
//  Created by wankang on 2/26/15.
//  Copyright (c) 2015 wankang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "UIStrokeView.h"
#import "StrokeRecordLoader.h"
//#import "NSChn2Py.h"
//#import "NSPy2Wave.h"

@interface StrokeViewContainer : NSObject<PlayChnSoundDelegate, StrokeDataDelegate, AVAudioPlayerDelegate> {
    // to load stroke record from stroke.db
    StrokeRecordLoader  *mLoader;
    // to play .wav file in iOS env.
    AVAudioPlayer       *mPlayer;
    // to notify playing-wave is finished
    id<PlaySoundEndNotify>  mNotify;
    // to convert Chn code to pinyin
    //NSChn2Py            *mChn2Py;
    // to convert pinyin to .wav file
    //NSPy2Wave           *mPy2Wave;
    // temporary .wav file, to be deleted on playing end
    NSString            *mTempWave;
}

@property (nonatomic) UIStrokeView *viewStroke;
@property (nonatomic) NSString *soundPath;

- (id)init;
- (id)initWithStrokeView:(UIStrokeView *)view;
- (void)dealloc;

- (void)close;
- (BOOL)initWithDBPath:(NSString *)sDBPath guidePath:(NSString *)sGuidePath;

// for PlayChnSoundDelegate
- (void)playSound:(NSString *)sChn forStroke:(BOOL)fStroke withNotify:(id<PlaySoundEndNotify>)notify;
// for StrokeDataDelegate
- (NSArray *)getStrokeForChn:(NSString *)sChn width:(NSInteger)maxWidth height:(NSInteger)maxHeight;
- (NSArray *)getGuideForChn:(NSString *)sChn withContourIndex:(NSInteger)index width:(NSInteger)maxWidth height:(NSInteger)maxHeight;
// for AVAudioPlayerDelegate
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag;
@end
